
package com.cust.zy.newtask.tools;

import java.io.File;
import java.io.IOException;

import android.content.Context;
import android.database.Cursor;
import android.media.ExifInterface;
import android.net.Uri;
import android.provider.MediaStore.MediaColumns;
/**
 * Created by zhuangyuan on 4/16/2017.
 * 邮箱：zhuangyuan.k@qq.com
 */
public class FileTool {

	/**
	 * Gets the original file path.
	 * 
	 * @param context
	 *            the context
	 * @param uri
	 *            the image uri
	 * @return the original file path
	 */
	public static String getOriginalFilePath(Context context, Uri uri) {
		if (uri.getScheme().equals("file")) {
			return uri.getPath();
		}
		String[] filePathColumn = { MediaColumns.DATA, MediaColumns.DATA };
		Cursor cursor = context.getContentResolver().query(uri,
				filePathColumn, null, null, null);
		cursor.moveToFirst();
		int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
		return cursor.getString(columnIndex);
	}
}
